package net.ming616.pattern.example.factory.initial;

import net.ming616.pattern.example.factory.product.media.audio.Audio;
import net.ming616.pattern.example.factory.product.media.audio.CD;
import net.ming616.pattern.example.factory.product.media.audio.MP3;
import net.ming616.pattern.example.factory.product.media.audio.WAV;

public class AudioPlayer {

	public void Play(String audioType) throws Exception {
		Audio audio = null;
		if (audioType.equals("MP3")) {
			audio = new MP3();
		} else if (audioType.equals("WAV")) {
			audio = new WAV();
		} else if (audioType.equals("CD")) {
			audio = new CD();
		} else {
			throw new Exception("unsupported audio format!");
		}
		audio.play();
	}

	public static void main(String[] args) throws Exception {
		AudioPlayer player = new AudioPlayer();
		player.Play("MP3");
	}
}
